package com.pingba.convert;

import com.pingba.entity.User;
import com.pingba.entity.oauth.WeCharUser;
import com.pingba.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 视图转化，返回客户端使用
 * Created by Administrator on 2015/12/9 0009.
 */
@Component
public class OauthConvert {

    /**
     * 将Wechar用户转化成pingba系统的用户
     * @param weCharUser
     * @return
     */
    public static User fromWechar(WeCharUser weCharUser) {
        User user = new User();
        user.setNickName(weCharUser.getNickName());
        user.setHeadUrl(weCharUser.getHeadImgUrl());
        user.setMale(weCharUser.getSex() == 1);
        user.setWecharUnionId(weCharUser.getUnionId());
        user.setRegTime(new Date().getTime());
        return user;
    }
}
